import {take,call,put,fork} from 'redux-saga/effects';
import getIndClassData from '../servers/serIndClass';

function *sagWatchIndClass() {
    while(true){
        yield take('INDCLASS');
        let payload=yield call(getIndClassData);
        let temPayload=[];
        let temPrivate=[{
            icn:'women',
            bgColor:'#ffc003'
        },
            {
                icn:'men',
                bgColor:'#f79407'
            },
            {
                icn:'computer',
                bgColor:'#f87bbc'
            },
            {
                icn:'mobile',
                bgColor:'#73bbff'
            },]
        if(payload.code===200){
            temPayload=payload.data;
            for (let i in temPayload){
                temPayload[i]['icn']=temPrivate[i]['icn']
                temPayload[i]['bgColor']=temPrivate[i]['bgColor']
            }
        }
        yield put({type:'indclass',data:{indClass:temPayload}})
    }
}
export default [
    fork(sagWatchIndClass)
]
